<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
{js href="/static/admin/lib/html5shiv.js,/static/admin/lib/respond.min.js"}
<![endif]-->
{css href="/static/admin/static/h-ui/css/H-ui.min.css,/static/admin/static/h-ui.admin/css/H-ui.admin.css,/static/admin/lib/Hui-iconfont/1.0.8/iconfont.css,/static/admin/static/h-ui.admin/skin/default/skin.css,/static/admin/static/h-ui.admin/css/style.css,/static/admin/lib/webuploader/0.1.5/webuploader.css"}
<!--[if IE 6]>
{js href="/static/admin/lib/DD_belatedPNG_0.0.8a-min.js"}
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>编辑试题分组 - 试题管理</title>
</head>
<body>
<article class="page-container">
	{if $data}
		<form class="form form-horizontal" id="form-admin-edit" action="/admin/questions/question/{$data.id}">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">封面：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<div class="uploader-thum-container">
						<div id="fileList" class="uploader-list" data-width="100" data-height="80">
							{if $data->cover}
							<div id="WU_FILE_0" class="item upload-state-success">
								<div class="pic-box"><img src="{$data.cover}" width="100"></div>
								<div class="info">{$data.cover}</div>
								<p class="state">已上传</p>
							</div>
							{/if}
						</div>
						<div id="filePicker">选择图片</div>
						<input type="hidden" name="cover" value="{$data.cover}">
					</div>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.title}" placeholder="" id="title" name="title">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试类型：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<select name="examination_type" class="select">
						<option value="0">请选择</option>
						{foreach $examination_type as $key => $_examination_type}
						<option value="{$_examination_type['id']}" {if $_examination_type['id'] == $data['examination_type']}selected{/if} >{$_examination_type.title}</option>
						{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试学段：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<select name="examination_section" class="select">
						<option value="0">请选择</option>
						{foreach $examination_section as $key => $_examination_section}
						<option value="{$_examination_section['id']}" {if $_examination_section['id'] == $data['examination_section']}selected{/if} >{$_examination_section.title}</option>
						{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试学科：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<select name="examination_discipline" class="select">
						<option value="0">请选择</option>
						{foreach $examination_discipline as $key => $_examination_discipline}
						<option value="{$_examination_discipline['id']}" {if $_examination_discipline['id'] == $data['examination_discipline']}selected{/if} >{$_examination_discipline.title}</option>
						{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试地区：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<select name="examination_area" class="select">
						<option value="0">请选择</option>
						{foreach $examination_area as $key => $_examination_area}
						<option value="{$_examination_area['id']}" {if $_examination_area['id'] == $data['examination_area']}selected{/if} >{$_examination_area.title}</option>
						{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">分类：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<select name="category" class="select">
						<option value="0">请选择</option>
						{foreach $question_category as $key => $_category}
							{if $_category.id != 2}
								<option value="{$_category.id}" {if $data.category==$_category.id}selected{/if}>{$_category.title}</option>
							{else/}
								<optgroup label="{$_category.title}">
									{if isset($_category->child)}
										{foreach $_category->child as $_child}
											<optgroup label="|-{$_child.title}">
												{if isset($_child->child)}
													{foreach $_child->child as $__child}
														<option value="{$__child.id}" {if $data.category==$__child.id}selected{/if}>|--{$__child.title}</option>
													{/foreach}
												{/if}
											</optgroup>
										{/foreach}
									{/if}
								</optgroup>
							{/if}
						{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否推荐：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					{foreach $config['recommend'] as $key => $_recommend}
					<div class="radio-box">
						<input name="recommend" type="radio" {if $key==$data['recommend']}checked{/if} id="recommend-{$key}" value="{$key}">
						<label for="recommend-{$key}">{$_recommend}</label>
					</div>
					{/foreach}
				</div>
			</div>
			{if can('admin/questions/Question/update')}
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			{/if}
		</form>
	{/if}
</article>

<!--_footer 作为公共模版分离出去-->
{js href="/static/admin/lib/jquery/1.9.1/jquery.min.js,/static/admin/lib/layer/2.4/layer.js,/static/admin/static/h-ui/js/H-ui.min.js,/static/admin/static/h-ui.admin/js/H-ui.admin.js"}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
{js href="/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js,/static/admin/lib/jquery.validation/1.14.0/validate-methods.js,/static/admin/lib/jquery.validation/1.14.0/messages_zh.js,/static/admin/static/gloab.js,/static/admin/static/gloab.css,/static/admin/lib/webuploader/0.1.5/webuploader.min.js,/static/admin/lib/My97DatePicker/4.8/WdatePicker.js,/static/admin/static/uploader/uploader.js"}
<script type="text/javascript">
$(function(){

    $('.textarea').Huitextarealength({
        maxlength:200
    });

	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-edit").validate({
		rules:{
            title : {
            	required : true,
				rangelength: [1, 100]
            },
            examination_type: {
                required: true,
                min: 1,
                digits: true
            },
            examination_section: {
                required: true,
                min: 1,
                digits: true
            },
            examination_discipline: {
                required: true,
                min: 1,
                digits: true
            },
            examination_area: {
                required: true,
                min: 1,
                digits: true
            },
            recommend: {
                required: true,
                min: 0,
                digits: true
            },
            category: {
            	min: 0,
				digits: true
            }
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'put',
                url: $(form).attr('action'),
                data: $(form).serialize(),
                success:function(data){
				    if ( data.code == 200 ) {
                        layer.msg('编辑成功',{icon:1,time:1000});
                    } else {
                        layer.msg('服务错误!',{icon:5,time:1000});
				    }
                },
                error:function(XmlHttpRequest, textStatus, errorThrown){
                    let errstr = XmlHttpRequest.responseText;
                    if ( errstr ) {
                        layer.msg($.parseJSON(errstr).message,{icon:5,time:1000});
                    } else {
                        layer.msg('服务错误!',{icon:5,time:1000});
                    }
                }
			});
			// var index = parent.layer.getFrameIndex(window.name);
			// parent.$('.btn-refresh').click();
			// parent.layer.close(index);
			return false;
		}
	});

	{if !$data}
    	layer.msg('资源不存在',{icon:5,time:2000});
	{/if}
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>